-
Notifications
You must be signed in to change notification settings - Fork 24
enhance(workflow): updating the test-coverage workflow #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe workflow configuration for test coverage was updated to trigger on both pull request and pull request target events for specific branches. The build job was renamed and restricted to run only on pull_request events with adjusted permissions. The checkout step now explicitly checks out the PR head commit. A new job was added to post JaCoCo coverage comments on pull requests after downloading the coverage artifact, running only on pull_request_target events with appropriate permissions. Changes
Sequence Diagram(s)sequenceDiagram
participant GitHub Actions
participant build-and-test-pr
participant post-coverage-comment
GitHub Actions->>build-and-test-pr: Trigger on pull_request (master/develop)
build-and-test-pr->>build-and-test-pr: Checkout PR head commit
build-and-test-pr->>build-and-test-pr: Run Maven tests
build-and-test-pr->>build-and-test-pr: Upload JaCoCo report artifact
build-and-test-pr-->>post-coverage-comment: Trigger on pull_request_target after success
post-coverage-comment->>post-coverage-comment: Checkout base branch
post-coverage-comment->>post-coverage-comment: Download JaCoCo artifact
post-coverage-comment->>post-coverage-comment: Run coverage comparison and post comment
Poem
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
.github/workflows/testcase-coverage.yml (3)
13-17: Tighten global permissions –issues: writeis unusedThe workflow never creates/edits issues, yet grants that permission.
Remove it to follow the principle of least privilege.permissions: contents: read pull-requests: write - issues: write
37-40: Cache Maven deps & run in batch mode for a 50-70 % speed-up- - name: Build with Maven and Run Tests - run: | - mvn clean verify -Dmaven.test.failure.ignore=false + - name: Cache & Build with Maven (tests) + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + - uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: maven-${{ hashFiles('**/pom.xml') }} + restore-keys: maven- + - run: mvn -B clean verifyCuts cold-start latency and keeps logs terser with
-B.
41-46: Minor path mismatch – upload single file, download into dirYou upload only
jacoco.xmlbut download intotarget/site/jacoco/.
Safer to keep semantics aligned to avoid empty directory surprises:- path: target/site/jacoco/jacoco.xml + path: target/site/jacoco/(or adjust the download path accordingly).
Also applies to: 62-67
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/testcase-coverage.yml(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Analyze (java)
🔇 Additional comments (1)
.github/workflows/testcase-coverage.yml (1)
68-74: Verify coverage diff accuracy – job runs on base commit but passes PR coverageBecause the step checks out the base branch then feeds it the PR’s coverage file,
madrapps/jacoco-reportmay compute deltas against itself, not the true head-vs-base diff.
Please confirm the action’s behaviour or swap the order:
- Download artifact
- Checkout PR head with
clean: falseso the workspace code matches the report.
|
|
This workflow is ready to merge , the jacoco report seems to be working now. will raise PR for the same on other API's as well |
@Zapper9982 Ensure the correct base branch for all the repos please. |
I didnt quite catch it , are u telling for the workflow or are u asking me to change the branch on which the Pr is put on ? |
|
@Zapper9982 branch - in which you put your PR's. Because. I found in some repo's you are pointing to release-3.4.0. But here you are pointing to develop. |
for Beneficiary API I have added on develop since there are no active changes , however other repos were evolving so I was asked to put a pr on 3.4.0 |



📋 Description
This pull request updates the GitHub Actions workflow,
TestCase Coverage Check, designed to automate the validation of test cases and code coverage.The primary motivation behind this change is to ensure that all pull requests maintain or improve code quality by:
Automatically running all unit tests and failing the build if any tests do not pass.
Generating a JaCoCo code coverage report.
Comparing the code coverage of the pull request's branch against the base branch (e.g.,
masterordevelop).Posting a comment on the pull request with a detailed breakdown of coverage changes, providing immediate feedback to developers.
This workflow addresses a previous
HttpError: Resource not accessible by integrationissue encountered when posting coverage comments on organization repositories, especially for pull requests originating from forked repositories. The new two-job structure (build-and-test-prandpost-coverage-comment) leveragespull_request_targetsecurely to grant the necessary write permissions for commenting, while maintaining a secure execution environment for untrusted code from forks.✅ Type of Change
🐞 Bug fix (non-breaking change which resolves an issue)
✨ New feature (non-breaking change which adds functionality)
🔥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
🛠 Refactor (change that is neither a fix nor a new feature)
⚙️ Config change (configuration file or build script updates)
📚 Documentation (updates to docs or readme)
🧪 Tests (adding new or updating existing tests)
🎨 UI/UX (changes that affect the user interface)
🚀 Performance (improves performance)
🧹 Chore (miscellaneous changes that don't modify src or test files)
ℹ️ Additional Information
Summary by CodeRabbit